Ext.namespace("Test");

Ext.onReady(function() {

	var textName = new Ext.form.TextField({

				fieldLabel : 'username',
				name : 'username'
			});

	var textPwd = new Ext.form.TextField({

				fieldLabel : 'password',
				id : 'password'
			});

	var myForm = new Ext.FormPanel({

				title : 'XML 2',
				renderTo : Ext.getBody(),
				frame : true,
				// height:400 ,
				width : 500,
				items : [textName, textPwd],
				buttons : [{

							text : 'XML',
							handler : login
						}]

			});

	function login() {
		var reqConfig = {
			url : '../jsp/server/loginServerXml.jsp',
			xmlData : getXml(),
			callback : function(options, success, response) {
				Ext.Msg.alert('Tips', success + '<br>' + response.responseText);
			}
		};
		Ext.Ajax.request(reqConfig);
	};

	function getXml() {
		var name = textName.getValue();
		var pwd = textPwd.getValue();
		var dom = new ActiveXObject("msxml2.DOMDocument");
		var header = dom.createProcessingInstruction('xml', "version='1.0'");
		dom.appendChild(header);
		var root = dom.createElement("loginInfo");
		var username = dom.createElement("userName");
		var userpassword = dom.createElement("passWord");
		username.text = name;
		userpassword.text = pwd;
		root.appendChild(username);
		root.appendChild(userpassword);
		dom.appendChild(root);
		return dom;
	};

});